<?php header("Content-type:text/html; Charset=utf-8");?>
<?php
	//wsyS Y
	class MySqls_1{
		var $N_GS ="wxyS辅助开发框架 版本：V2.0"; 
		var $N_LBZ ="PHP操作MySQL模块1"; 
		var $N_BQ = "版权归属：230104198110270213";
		var $MySqlcon;
		function __construct(){}/*_construct*/
		function lj_Json1(){
			$url = $_SERVER['DOCUMENT_ROOT']."DAY/DAY4/File/json/Data_xx.json";
			$json_Str1 = file_get_contents($url);
			$arr_sl1 = json_decode($json_Str1,true);
			return $arr_sl1;
		}//lj_Json1
		function Open_1(){
			$connErrBJ1 = '0';
			$arr_sl1 = $this->lj_Json1();
			$BL1 = $arr_sl1['MySql_1']['server'];
			$BL2 = $arr_sl1['MySql_1']['user']; 
			$BL3 = $arr_sl1['MySql_1']['password']; 
			$BL4 = $arr_sl1['MySql_1']['dbname'];
			$this->MySqlcon = mysqli_connect($BL1,$BL2,$BL3,$BL4);//连接实例
			// 检测连接
			if (!$this->MySqlcon) {
				//die("连接失败: ". mysqli_connect_error();
				//$N_FHZ001 = '连接MySql数据库发生异常!';
				$connErrBJ1 = 'MySql1';
			}else{
				//mysqli_query("set names utf-8");//编码转化
				// 修改数据库连接字符集为 utf8
				mysqli_set_charset($this->MySqlcon,"utf8");
				$connErrBJ1 = '0';
			}
			return $connErrBJ1;
		}//Open_1
		function Close_1(){
			$connErrBJ1 = '0';
			try{
				mysqli_close($this->MySqlcon);
				$connErrBJ1 = '0';
			}
			catch(Exception $e)
			{
				$connErrBJ1 = 'MySql2';
			}
			return $connErrBJ1;
		}//Close_1
		
		
		//通用I，D,U
		function IDUys1($Sql1){
			$DZsql1 = $Sql1;
			$connErrBJ1 = '1';
			if(mysqli_query($this->MySqlcon,$DZsql1)){//$this->
				$connErrBJ1 = '0';
			}else{
				$connErrBJ1 = '1';
			}//
			return $connErrBJ1;
		}//IDUys1
		//查询记录数
		function CXysSL1($Sql1){
			$DZsql1 = "select count(*) as Selsl1sl from " . $Sql1 . ";";
			$connErrBJ1 = '0';
			//发送sql语句
    		$obj = mysqli_query($this->MySqlcon,$DZsql1);
			$row = mysqli_fetch_assoc($obj);
			$connErrBJ1 = $row['Selsl1sl'];
			return $connErrBJ1;
		}//CXysSL1
		//通过序号获取数据
		function CXysZD1($tablename,$SqlQ1='*',$SqlH1='$NULL$'){
			$DZsql1 =  "select ".$SqlQ1." from ". $tablename;
			if($SqlH1!='$NULL$'){
				$DZsql1 = $DZsql1 . " " . $SqlH1;
			}
			$DZsql1 = $DZsql1 . ";";
			$connErrBJ1 = '';
			//发送sql语句
    		$obj = mysqli_query($this->MySqlcon,$DZsql1);
			$connErrBJ1 = '';
			$leijl1 = 0;
			while($row =mysqli_fetch_row($obj)){
				// mysqli_fetch_assoc($obj):字段取数
				// mysqli_fetch_row($obj):编号取数
				$ii1 = sizeof($row);
				$iii1 = 0;
				if($leijl1 != 0){
					$connErrBJ1 = $connErrBJ1 . '$1$';
				}
				while($iii1<$ii1){
					if($iii1>0){
						$connErrBJ1 = $connErrBJ1 . "$2$";
					}//
					$connErrBJ1 = $connErrBJ1 . $row[$iii1];
					$iii1 = $iii1 + 1;
				}//
				$iii1 = 0;
				$leijl1 = $leijl1 + 1;
			}//while
			$leijl1 = 0;
			return $connErrBJ1;
		}//CXysSL1
		
		function CXysZD2($tablename,$SqlQ1='*',$SqlH1='$NULL$',$RDarray1=array(0),$rdsl='$NULL$'){
			$DZsql1 =  "select ".$SqlQ1." from ". $tablename;
			if($SqlH1!='$NULL$'){
				$DZsql1 = $DZsql1 . " " . $SqlH1;
			}
			$DZsql1 = $DZsql1 . ";";
			$connErrBJ1 = '';
			//发送sql语句
    		$obj = mysqli_query($this->MySqlcon,$DZsql1);
			$connErrBJ1 = '';
			$leijl1 = 0;
			if(sizeof($RDarray1)!=0){
				while($row =mysqli_fetch_assoc($obj)){
					// mysqli_fetch_assoc($obj):字段取数
					// mysqli_fetch_row($obj):编号取数
					$ii1 = sizeof($RDarray1);
					$ii1 = $rdsl =='$NULL$'? $ii1:(int)$rdsl;
					$iii1 = 0;
					if($leijl1 != 0){
						$connErrBJ1 = $connErrBJ1 . '$1$';
					}
					while($iii1<$ii1){
						if($iii1>0){
							$connErrBJ1 = $connErrBJ1 . "$2$";
						}//
						$connErrBJ1 = $connErrBJ1 . $row[$RDarray1[$iii1]];
						$iii1 = $iii1 + 1;
					}//
					$iii1 = 0;
					$leijl1 = $leijl1 + 1;
				}//while
			}else{
				$connErrBJ1 = '$WXYNULL$';
			}//if(sizeof($RDarray1)==0
			$leijl1 = 0;
			return $connErrBJ1;
		}//CXysZD2

		function  __destruct(){}/*_destruct*/
	}//MySqls_1 wei
/*
$sl = new MySqls_1();
echo $sl->Open_1();
*/

?>